// 封装获取频道列表的逻辑
// hooks 这里一次获取，外部有两个地方用到，直接导入使用
import { useEffect, useState } from "react";
import { getChannelAPI } from "@/apis/article";

function useChannel() {
    // 获取频道列表
    const [channelList, setChannelList] = useState([])
    useEffect(() => {
        const getChannelList = async () => {
            const res = await getChannelAPI()
            setChannelList(res.data.channels)
        }
        getChannelList()
    }, [])

    return {
        channelList
    }
}

export { useChannel }

